package icu.lookyousmileface.config;

import com.baomidou.mybatisplus.core.injector.DefaultSqlInjector;
import com.baomidou.mybatisplus.core.injector.ISqlInjector;
import com.baomidou.mybatisplus.extension.plugins.OptimisticLockerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**
 * @author starrysky
 * @title: MybatisPlusConfig
 * @projectName mybaits_plus_final
 * @description: 配置类
 * @date 2021/1/3123:59
 */
/**
 * 开启事务注解
 */
@EnableTransactionManagement
@MapperScan("icu.lookyousmileface.mapper")
@Configuration
public class MybatisPlusConfig {

    /**
     * 乐观锁
     * @return new OptimisticLockerInterceptor()
     */
    @Bean
    public OptimisticLockerInterceptor optimisticLockerInterceptor(){
        return new OptimisticLockerInterceptor();
    }

    /**
     * mybatis-plus的分页插件
     * @return new PaginationInterceptor()
     */
    @Bean
    public PaginationInterceptor paginationInterceptor(){
        return new PaginationInterceptor();
    }

    /**
     * 逻辑删除插件
     */
    @Bean
    public ISqlInjector injector(){
        return new DefaultSqlInjector();
    }


}
